import { WeaLocaleProvider,WeaTools } from "ecCom";
import {message} from "antd";

const getLabel = WeaLocaleProvider.getLabel;

export default {
	href: {
		user: (userId) => `/spa/hrm/index_mobx.html#/main/hrm/card/cardInfo/${userId}`,//人事信息页面
		blog: (blogId) => `/spa/blog/static/index.html#/user/${blogId}`,//微博信息页面
        // blog: (blogId) => `/blog/viewBlog.jsp?blogid=${blogId}`,//微博信息页面
        dept: (deptId) => `/spa/hrm/engine.html#/hrmengine/organization?showTree=false&isView=1&type=department&id=${deptId}`,//部门页面
        viewAttentionUser: (userId) => `main/blog/myAttention/user/${userId}`,
        viewAttentionUserPar: (userId,tab) => `main/blog/myAttention/user/${userId}/${tab}`,
        viewAttentionList: () => `main/blog/myAttention/list`
	},
    addWindowFunc: () => {
        let openFullWindowHaveBar = (url) => {
            var redirectUrl = url;
            var width = screen.availWidth - 10;
            var height = screen.availHeight - 50;
            var szFeatures = "top=0,";
            szFeatures += "left=0,";
            szFeatures += "width=" + width + ",";
            szFeatures += "height=" + height + ",";
            szFeatures += "directories=no,";
            szFeatures += "status=yes,toolbar=no,location=no,";
            szFeatures += "menubar=no,";
            szFeatures += "scrollbars=yes,";
            szFeatures += "resizable=yes"; //channelmode
            window.open(redirectUrl, "", szFeatures);
        }
    
        //打开应用连接
        window.openAppLink = (obj, linkid) => {
            var linkType = jQuery(obj).attr("linkType");
            var discussid = jQuery(obj).parents(".reportItem").attr("id");
            if (linkType == "doc")
                window.open("/spa/document/index.jsp?moduleid=blog&id=" + linkid + "&discussid=" + discussid + "&linkType=" + linkType + "&linkid=" + linkid);
            else if (linkType == "task")
                window.open("/spa/prj/index.html#/main/prj/taskCard?moduleid=blog&taskid=" + linkid + "&discussid=" + discussid + "&linkType=" + linkType + "&linkid=" + linkid);
            else if (linkType == "crm")
                //标准e9,勿删
                window.open("/spa/crm/static/index.html#/main/crm/customerView?customerId=" + linkid + "&discussid=" + discussid + "&linkType=" + linkType + "&linkid=" + linkid);
                //ecology正式系统定制,勿删
                // window.open("/CRM/manage/customer/CustomerBaseView.jsp?CustomerID=" + linkid );
            else if (linkType == "workflow")
                window.open("/workflow/request/ViewRequestForwardSPA.jsp?moduleid=blog&requestid=" + linkid + "&discussid=" + discussid + "&linkType=" + linkType + "&linkid=" + linkid);
            else if (linkType == "project")
                window.open("/spa/prj/index.html#/main/prj/projectCard?moduleid=blog&prjid=" + linkid + "&discussid=" + discussid + "&linkType=" + linkType + "&linkid=" + linkid);
            else if (linkType == "workplan")
                window.open("/spa/workplan/static/index.html#/main/wp/workPlanCreateSingle?moduleid=blog&workPlanId=" + linkid + "&discussid=" + discussid + "&linkType=" + linkType + "&linkid=" + linkid);
            return false;
        }
        //打开附件
        window.opendoc = (showid, versionid, docImagefileid, obj) => {
            var discussid = jQuery(obj).parents(".reportItem").attr("id");
            openFullWindowHaveBar("/docs/docs/DocDspExt.jsp?id=" + showid + "&imagefileId=" + docImagefileid + "&blogDiscussid=" + discussid + "&isFromAccessory=true&isfromcoworkdoc=1");
        }
        //打开附件
        window.opendoc1 = (showid, obj) => {
			var discussid = jQuery(obj).parents(".reportItem").attr("id");
			//加上这个参数，会默认无法预览pstate=sub
	   		//openFullWindowHaveBar("/docs/docs/DocDsp.jsp?id="+showid+"&blogDiscussid="+discussid+"&pstate=sub");
			//openFullWindowHaveBar("/docs/docs/DocDsp.jsp?id=" + showid + "&blogDiscussid=" + discussid); //E8

            //请求一个接口添加文档查看权限
            WeaTools.callApi('/api/blog/attach/AddBlogDocShare','POST',{
                jsonStr: JSON.stringify({
                    "blogid":discussid,
                    "docid":showid,
                })
            }).then((result) =>{
                if(result.status=="1"){
                    openFullWindowHaveBar("/spa/document/index.jsp?id=" + showid + "&router=1&blogDiscussid=" + discussid + "#/main/document/detail"); //E9
                }
            })

        }
        //下载附件
        window.downloads = (files, obj) => {

            var discussid = jQuery(obj).parents(".reportItem").attr("id");
            WeaTools.callApi('/api/blog/attach/AddBlogDocShare','POST',{
                jsonStr: JSON.stringify({
                    "blogid":discussid,
                    "docid":files,
                })
            }).then((result) =>{
                if(result.status=="1"){
                    window.open("/weaver/weaver.file.FileDownload?fileid=" + files + "&download=1&blogDiscussid=" + discussid)
                }
            })
            //请求一个接口添加下载权限
            //jQuery("#downloadFrame").attr("src", "/weaver/weaver.file.FileDownload?fileid=" + files + "&download=1&blogDiscussid=" + discussid);

        }

        window.openBlog = (blogid)=>{
            var url="/blog/viewBlog.jsp?blogid="+blogid;
            window.open(url);
         }
    },
    bottomBarMirror: {
        Document: {type: 37, name: '文档', icon: 'icon-blog-Document',nameFunc:() => getLabel(22243,"文档")},
        Schedule: {type: 'workplan', name: '日程', icon: 'icon-blog-Schedule',nameFunc:() => getLabel(83466,"日程")},
        Flow: {type: 152, name: '流程', icon: 'icon-blog-Process',nameFunc:() => getLabel(30045,"流程")},
        Customer: {type: 18, name: '客户', icon: 'icon-blog-Personnel',nameFunc:() => getLabel(136,"客户")},
        Project: {type: 135, name: '项目', icon: 'icon-blog-Project',nameFunc:() => getLabel(101,"项目")},
        Task: {type: 'prjtsk', name: '任务', icon: 'icon-blog-Task',nameFunc:() => getLabel(1332,"任务")},
        Templet: {type: 'blogTemplate', name: '模板', icon: 'icon-blog-Task',nameFunc:() => getLabel(33144,"模板")},
    }
    
};